package com.allenlee.mvphelper.module.login;

import com.allenlee.mvphelper.base.bean.HttpResult;
import com.allenlee.mvphelper.net.retrofit.RetrofitClient;
import com.allenlee.mvphelper.net.retrofit.exception.APIException;

import org.reactivestreams.Subscription;

import java.util.HashMap;

import io.reactivex.Flowable;
import io.reactivex.functions.Consumer;

/**
 * @author : lifei
 * 创建时间： 19-11-28
 * 更改时间： 19-11-28
 * Email : allen.lee723@qq.com
 * @version :
 * Description：
 */
public class LoginModel implements LoginContract.Model {

    @Override
    public Flowable<HttpResult<LoginBean>> login(HashMap<String, String> params) {
        return RetrofitClient.getInstance().getApi().login(params).doOnSubscribe(new Consumer<Subscription>() {
            @Override
            public void accept(Subscription subscription) throws Exception {
                APIException.checkParam(params);
            }
        });
    }

    @Override
    public Flowable<HttpResult<LoginBean>> getLoginInfo() {
        return RetrofitClient.getInstance().getApi().getLoginInfo();
    }
}